import request from '@/utils/request'

//  分页查询用户信息
export function handlePageList(query) {
  return request({
    url: '/api/admin/system/user/page',
    method: 'post',
    data: query
  })
}

//  查询用户列表信息
export function handleList(query) {
  return request({
    url: '/api/admin/system/user/list',
    method: 'post',
    data: query
  })
}

//  查询用户信息
export function handleDetail(data) {
  return request({
    url: '/api/admin/system/user/detail',
    method: 'post',
    params: data
  })
}

// 获取所有的用户信息
export function handleGetAllUserList() {
  return request({
    url: '/api/admin/system/user/getAllUserList',
    method: 'get'
  })
}

//  保存用户信息
export function handleSave(data) {
  return request({
    url: '/api/admin/system/user/save',
    method: 'post',
    data: data
  })
}

//  删除用户信息
export function handleDelete(data) {
  return request({
    url: '/api/admin/system/user/delete',
    method: 'post',
    params: data
  })
}

//  重置用户密码
export function handlePwd(data) {
  return request({
    url: '/api/admin/system/user/reset',
    method: 'post',
    params: data
  })
}

//  查询用户角色信息
export function getUserRoles(data) {
  return request({
    url: '/api/admin/system/user/role/list',
    method: 'post',
    data: data
  })
}
export function updateProfile(data) {
  return request({
    url: '/api/admin/system/user/updateProfile',
    method: 'post',
    data: data
  })
}

export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/api/admin/system/user/updateUserPwd',
    method: 'post',
    data: data
  })
}
